export interface ReqAdminAddParams {
  phone: 'mobile'
  account: string
  pwd: string
  passwordConfirm: string
  nickName: string
  email?: string
  weChartAccount?: string
  roles?: (string | number)[]
  descption?: string
}

// 新增
export function addApi(params: ReqAdminAddParams) {
  return usePost<any>('/admin/add', params, {
    // 设置为false的时候不会携带token
    token: true,
    // 开发模式下使用自定义的接口
    customDev: true,
    // 是否开启全局请求loading
    loading: true,
  })
}

// 删除
export async function delApi(ids: string) {
  return useDelete(`/admin/delete/${ids}`)
}
// 修改
export interface ReqAdminUpdateParams {
  phone: 'mobile'
  passwordConfirm: string
  nickName: string
  email?: string
  weChartAccount?: string
  roles?: (string | number)[]
  descption?: string
}
export function updateApi(params: ReqAdminUpdateParams, id: string) {
  return usePut(`/admin/update/${id}`, params, {
    // 设置为false的时候不会携带token
    token: true,
    // 开发模式下使用自定义的接口
    customDev: true,
    // 是否开启全局请求loading
    loading: true,
  })
}

// 查询
export interface ReqAdminQueryParams {
  phone: 'mobile'
  account: string
  nickName: string
  email?: string
  weChartAccount?: string
  status?: boolean
  pageNo?: number
  pageSize?: number
}

export interface RepPage {
  pageNo?: number
  pageSize?: number
  totalCount?: number
  totalPage?: number
  data?: RepAdminInfo[]
}

export interface RepAdminInfo {
  id: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  phone: string
  account: string
  nickName: string
  email: string
  weChartAccount: string
  roles: []
  status: boolean
  descption: string
}
export function queryApi(params: ReqAdminQueryParams) {
  return usePost<RepPage>('/admin/pages', params, {
    // 设置为false的时候不会携带token
    token: true,
    // 开发模式下使用自定义的接口
    customDev: true,
    // 是否开启全局请求loading
    loading: true,
  })
}
